local hx__yanguilai = fk.CreateSkill {
  name = "hx__yanguilai",
}

hx__yanguilai:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if target == player and player:hasSkill(hx__yanguilai.name) then
      local card = table.filter(player:getCardIds("h"), function(id) return Fk:getCardById(id):getMark("@@hx__yanguilai-inhand") > 0 end)
      if #card > 0 then return end
      local use_events = player.room.logic:getEventsByRule(GameEvent.UseCard, 1, function (e)
        if e.id < player.room.logic:getCurrentEvent().id then
          return e.data.from == player
        end
      end, 0, Player.HistoryGame)
      return #use_events == 1 and use_events[1].data.card.type == data.card.type
    end
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(2, hx__yanguilai.name,nil,"@@hx__yanguilai-inhand")
  end,
})

return hx__yanguilai